#include "stdafx.h"


	namespace network
	{
		namespace packet
		{

			// RequestSpawnEntity
			RequestNeedGenerikAdd::RequestNeedGenerikAdd( ) :
				Event::EventNeedGenerikAdd(),
				buffer::BasicBuffer(  sizeof( boost::uint8_t) * 3 + sizeof( boost::uint32_t ) + sizeof( float ) * 3 , (int)Event::EVENT_NEED_GENERIK_ADD),
				BasicPacket((int)Event::EVENT_NEED_GENERIK_ADD)
			{
			}
			
			RequestNeedGenerikAdd::RequestNeedGenerikAdd( boost::uint8_t _type, boost::uint32_t _objectId, boost::uint8_t _phase, boost::uint8_t _age, irr::core::vector3df _position ) :
				Event::EventNeedGenerikAdd( (void*)NULL, _type, _objectId, _phase, _age, _position,0,0 ),
				buffer::BasicBuffer( sizeof( boost::uint8_t) * 3 + sizeof( boost::uint32_t ) + sizeof( float ) * 3, (int)Event::EVENT_NEED_GENERIK_ADD),
				BasicPacket((int)Event::EVENT_NEED_GENERIK_ADD)
			{
				put<boost::uint8_t>(_type);
				put<boost::uint32_t>(_objectId);
				put<boost::uint8_t>(_phase);
				put<boost::uint8_t>(_age);
				put<float>( _position.X );
				put<float>( _position.Y );
				put<float>( _position.Z );
			}

			RequestNeedGenerikAdd::RequestNeedGenerikAdd( const buffer::BasicBuffer& _copy ) :
				Event::EventNeedGenerikAdd(),
				buffer::BasicBuffer(_copy),
				BasicPacket((int)Event::EVENT_NEED_GENERIK_ADD)
			{
				boost::uint8_t temp8=0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventNeedGenerikAdd::m_type = temp8;
				boost::uint32_t temp32 = 0;
				get_at_offset( &temp32, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t) );
				Event::EventNeedGenerikAdd::m_idToAdd = temp32;
				temp8 = 0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2  + sizeof( boost::uint8_t)  + sizeof( boost::uint32_t));
				Event::EventNeedGenerikAdd::m_phase = temp8;
				temp8 = 0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2  + sizeof( boost::uint8_t) * 2 + sizeof( boost::uint32_t) );
				Event::EventNeedGenerikAdd::m_age = temp8;

				float tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t)  + sizeof( boost::uint8_t) * 3 );
				Event::EventNeedGenerikAdd::m_position.X = tempf;
				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t)  + sizeof( boost::uint8_t) * 3 + sizeof( float ) );
				Event::EventNeedGenerikAdd::m_position.Y = tempf;
				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t)  + sizeof( boost::uint8_t) * 3 + sizeof( float ) * 2);
				Event::EventNeedGenerikAdd::m_position.Z = tempf;
			}

			RequestNeedGenerikAdd::RequestNeedGenerikAdd( const RequestNeedGenerikAdd& _copy ) :
				Event::EventNeedGenerikAdd(_copy),
				buffer::BasicBuffer(_copy),
				BasicPacket(_copy)
			{
			}

			RequestNeedGenerikAdd::RequestNeedGenerikAdd(boost::shared_ptr< std::vector< unsigned char > > _receive_buffer) :
				Event::EventNeedGenerikAdd(),
				buffer::BasicBuffer(_receive_buffer),
				BasicPacket(getId())
			{
				boost::uint8_t temp8=0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventNeedGenerikAdd::m_type = temp8;
				boost::uint32_t temp32 = 0;
				get_at_offset( &temp32, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t) );
				Event::EventNeedGenerikAdd::m_idToAdd = temp32;
				temp8 = 0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2  + sizeof( boost::uint8_t)  + sizeof( boost::uint32_t));
				Event::EventNeedGenerikAdd::m_phase = temp8;
				temp8 = 0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2  + sizeof( boost::uint8_t) * 2 + sizeof( boost::uint32_t) );
				Event::EventNeedGenerikAdd::m_age = temp8;

				float tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t)  + sizeof( boost::uint8_t) * 3 );
				Event::EventNeedGenerikAdd::m_position.X = tempf;
				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t)  + sizeof( boost::uint8_t) * 3 + sizeof( float ) );
				Event::EventNeedGenerikAdd::m_position.Y = tempf;
				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t)  + sizeof( boost::uint8_t) * 3 + sizeof( float ) * 2);
				Event::EventNeedGenerikAdd::m_position.Z = tempf;
			}

			void RequestNeedGenerikAdd::handle( session_ptr _session, buffer::BasicBuffer& _packet)
			{
				RequestNeedGenerikAdd packet(_packet);
				_session->on_packet( packet );
			}


			RequestNeedGenerikRemove::RequestNeedGenerikRemove( ) :
				Event::EventNeedGenerikRemove(),
				buffer::BasicBuffer( sizeof( boost::uint8_t) + sizeof( boost::uint32_t ), (int)Event::EVENT_NEED_GENERIK_REMOVE),
				BasicPacket((int)Event::EVENT_NEED_GENERIK_REMOVE)
			{
			}
			
			RequestNeedGenerikRemove::RequestNeedGenerikRemove(  boost::uint8_t _type, boost::uint32_t _idToRemove  ) :
				Event::EventNeedGenerikRemove( (void*)NULL,_type, _idToRemove,0,0 ),
				buffer::BasicBuffer( sizeof( boost::uint8_t) + sizeof( boost::uint32_t ), (int)Event::EVENT_NEED_GENERIK_REMOVE),
				BasicPacket((int)Event::EVENT_NEED_GENERIK_REMOVE)
			{
				put<boost::uint8_t>(_type);
				put<boost::uint32_t>(_idToRemove);
			}

			RequestNeedGenerikRemove::RequestNeedGenerikRemove( const buffer::BasicBuffer& _copy ) :
				Event::EventNeedGenerikRemove(),
				buffer::BasicBuffer(_copy),
				BasicPacket((int)Event::EVENT_NEED_GENERIK_REMOVE)
			{
				boost::uint8_t temp8=0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventNeedGenerikRemove::m_type = temp8;
				boost::uint32_t temp32 = 0;
				get_at_offset( &temp32, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) );
				Event::EventNeedGenerikRemove::m_idToRemove = temp32;
			}

			RequestNeedGenerikRemove::RequestNeedGenerikRemove( const RequestNeedGenerikRemove& _copy ) :
				Event::EventNeedGenerikRemove(_copy),
				buffer::BasicBuffer(_copy),
				BasicPacket(_copy)
			{
			}

			RequestNeedGenerikRemove::RequestNeedGenerikRemove(boost::shared_ptr< std::vector< unsigned char > > _receive_buffer) :
				Event::EventNeedGenerikRemove(),
				buffer::BasicBuffer(_receive_buffer),
				BasicPacket(getId())
			{
				boost::uint8_t temp8=0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventNeedGenerikRemove::m_type = temp8;
				boost::uint32_t temp32 = 0;
				get_at_offset( &temp32, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) );
				Event::EventNeedGenerikRemove::m_idToRemove = temp32;
			}

			void RequestNeedGenerikRemove::handle( session_ptr _session, buffer::BasicBuffer& _packet)
			{
				RequestNeedGenerikRemove packet(_packet);
				_session->on_packet( packet );
			}



			// RequestNeedGenerikScentAdd
			RequestNeedGenerikScentAdd::RequestNeedGenerikScentAdd( ) :
				Event::EventNeedGenerikScentAdd(),
				buffer::BasicBuffer(sizeof( boost::uint8_t) + sizeof( boost::uint32_t ) + sizeof( float ) * 3 , (int)Event::EVENT_NEED_GENERIK_SCENT_ADD),
				BasicPacket((int)Event::EVENT_NEED_GENERIK_SCENT_ADD)
			{
			}
			
			RequestNeedGenerikScentAdd::RequestNeedGenerikScentAdd( boost::uint8_t _type, float _posX, float _posY, float _posZ, boost::uint32_t _numToAdd ) :
				Event::EventNeedGenerikScentAdd( (void*)NULL,_type, _posX,_posZ, _numToAdd,0,0 ),
				buffer::BasicBuffer( sizeof( boost::uint8_t) + sizeof( boost::uint32_t ) + sizeof( float ) * 3, (int)Event::EVENT_NEED_GENERIK_SCENT_ADD),
				BasicPacket((int)Event::EVENT_NEED_GENERIK_SCENT_ADD)
			{
				put<boost::uint8_t>(_type);
				put<float>(_posX);
				put<float>(_posY);
				put<float>(_posZ);
				put<boost::uint32_t>(_numToAdd);
			}

			RequestNeedGenerikScentAdd::RequestNeedGenerikScentAdd( const buffer::BasicBuffer& _copy ) :
				Event::EventNeedGenerikScentAdd(),
				buffer::BasicBuffer(_copy),
				BasicPacket((int)Event::EVENT_NEED_GENERIK_SCENT_ADD)
			{
				boost::uint8_t temp8 = 0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventNeedGenerikScentAdd::m_type = temp8;
				
				float tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) );
				Event::EventNeedGenerikScentAdd::m_posX = tempf;

				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) + sizeof( float ) );
				//Event::EventEntitySpawned::m_posY = tempf;

				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) + sizeof( float ) * 2 );
				Event::EventNeedGenerikScentAdd::m_posZ = tempf;
				
				int temp32 = 0;
				get_at_offset( &temp32, sizeof( int ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) + sizeof( float ) * 3 );
				Event::EventNeedGenerikScentAdd::m_numToAdd = temp32;
			}

			RequestNeedGenerikScentAdd::RequestNeedGenerikScentAdd( const RequestNeedGenerikScentAdd& _copy ) :
				Event::EventNeedGenerikScentAdd(_copy),
				buffer::BasicBuffer(_copy),
				BasicPacket(_copy)
			{
			}

			RequestNeedGenerikScentAdd::RequestNeedGenerikScentAdd(boost::shared_ptr< std::vector< unsigned char > > _receive_buffer) :
				Event::EventNeedGenerikScentAdd(),
				buffer::BasicBuffer(_receive_buffer),
				BasicPacket(getId())
			{
				
				boost::uint8_t temp8 = 0;
				get_at_offset( &temp8, sizeof( boost::uint8_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventNeedGenerikScentAdd::m_type = temp8;
				
				float tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) );
				Event::EventNeedGenerikScentAdd::m_posX = tempf;

				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) + sizeof( float ) );
				//Event::EventEntitySpawned::m_posY = tempf;

				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) + sizeof( float ) * 2 );
				Event::EventNeedGenerikScentAdd::m_posZ = tempf;
				
				int temp32 = 0;
				get_at_offset( &temp32, sizeof( int ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint8_t ) + sizeof( float ) * 3 );
				Event::EventNeedGenerikScentAdd::m_numToAdd = temp32;
			}

			void RequestNeedGenerikScentAdd::handle( session_ptr _session, buffer::BasicBuffer& _packet)
			{
				RequestNeedGenerikScentAdd packet(_packet);
				_session->on_packet( packet );
			}

			// RequestGrow
			RequestGrow::RequestGrow( ) :
				Event::EventGrow(),
				buffer::BasicBuffer( sizeof( boost::uint32_t ) * 2 , (int) Event::EVENT_GROW),
				BasicPacket( (int) Event::EVENT_GROW)
			{
			}
			
			RequestGrow::RequestGrow( boost::uint32_t _idToChange, boost::uint32_t _newAge ) :
				Event::EventGrow( (void*)NULL, _idToChange, _newAge, 0, 0 ),
				buffer::BasicBuffer( sizeof( boost::uint32_t ) * 2,  (int) Event::EVENT_GROW),
				BasicPacket( (int) Event::EVENT_GROW)
			{
				put<boost::uint32_t>(_idToChange);
				put<boost::uint32_t>(_newAge);
			}

			RequestGrow::RequestGrow( const buffer::BasicBuffer& _copy ) :
				Event::EventGrow(),
				buffer::BasicBuffer(_copy),
				BasicPacket( (int) Event::EVENT_GROW)
			{
				boost::uint32_t temp = 0;
				get_at_offset( &temp, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventGrow::m_idToChange = temp;
				temp = 0;
				get_at_offset( &temp, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t) );
				Event::EventGrow::m_newAge = temp;
			}

			RequestGrow::RequestGrow( const RequestGrow& _copy ) :
				Event::EventGrow(_copy),
				buffer::BasicBuffer(_copy),
				BasicPacket(_copy)
			{
			}

			RequestGrow::RequestGrow(boost::shared_ptr< std::vector< unsigned char > > _receive_buffer) :
				Event::EventGrow(),
				buffer::BasicBuffer(_receive_buffer),
				BasicPacket(getId())
			{
				boost::uint32_t temp = 0;
				get_at_offset( &temp, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventGrow::m_idToChange = temp;
				temp = 0;
				get_at_offset( &temp, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t) );
				Event::EventGrow::m_newAge = temp;
			}

			void RequestGrow::handle( session_ptr _session, buffer::BasicBuffer& _packet)
			{
				RequestGrow packet(_packet);
				_session->on_packet( packet );
			}



			
			// RequestChangePosition
			RequestChangePosition::RequestChangePosition( ) :
				Event::EventChangePosition(),
				buffer::BasicBuffer( sizeof( boost::uint32_t) + sizeof( float ) * 3, (int) Event::EVENT_CHANGE_POSITION),
				BasicPacket((int) Event::EVENT_CHANGE_POSITION)
			{
			}
			
			RequestChangePosition::RequestChangePosition( boost::uint32_t _idToChange, const irr::core::vector3df& _newPos ) :
				Event::EventChangePosition((void*)NULL, _idToChange, _newPos, 0, 0),
				buffer::BasicBuffer( sizeof( boost::uint32_t) + sizeof( float ) * 3, (int) Event::EVENT_CHANGE_POSITION),
				BasicPacket((int) Event::EVENT_CHANGE_POSITION)
			{
				put<boost::uint32_t>(_idToChange);
				put<float>(_newPos.X);
				put<float>(_newPos.Y);
				put<float>(_newPos.Z);
			}

			RequestChangePosition::RequestChangePosition( const buffer::BasicBuffer& _copy ) :
				Event::EventChangePosition(),
				buffer::BasicBuffer(_copy),
				BasicPacket((int) Event::EVENT_CHANGE_POSITION)
			{
				boost::uint32_t temp=0;
				get_at_offset( &temp, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventChangePosition::m_idToChange = temp;
				float tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t) );
				Event::EventChangePosition::m_newPosition.X = tempf;
				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t) + sizeof( float ));
				Event::EventChangePosition::m_newPosition.Y = tempf;
				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t) + sizeof( float ) * 2);
				Event::EventChangePosition::m_newPosition.Z = tempf;
			}

			RequestChangePosition::RequestChangePosition( const RequestChangePosition& _copy ) :
				Event::EventChangePosition(_copy),
				buffer::BasicBuffer(_copy),
				BasicPacket(_copy)
			{
			}

			RequestChangePosition::RequestChangePosition(boost::shared_ptr< std::vector< unsigned char > > _receive_buffer) :
				Event::EventChangePosition(),
				buffer::BasicBuffer(_receive_buffer),
				BasicPacket(getId())
			{
				boost::uint32_t temp=0;
				get_at_offset( &temp, sizeof( boost::uint32_t ), sizeof( boost::uint16_t ) * 2);
				Event::EventChangePosition::m_idToChange = temp;
				float tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t) );
				Event::EventChangePosition::m_newPosition.X = tempf;
				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t) + sizeof( float ));
				Event::EventChangePosition::m_newPosition.Y = tempf;
				tempf = 0;
				get_at_offset( &tempf, sizeof( float ), sizeof( boost::uint16_t ) * 2 + sizeof( boost::uint32_t) + sizeof( float ) * 2);
				Event::EventChangePosition::m_newPosition.Z = tempf;
			}

			void RequestChangePosition::handle( session_ptr _session, buffer::BasicBuffer& _packet)
			{
				RequestChangePosition packet(_packet);
				_session->on_packet( packet );
			}


			// RequestGeneriks
			RequestGeneriks::RequestGeneriks( ) :
				Event::EventRequestGeneriks(),
				network::buffer::BasicBuffer( 0 , (int)Event::EVENT_REQUEST_GENERIKS),
				network::packet::BasicPacket((int)Event::EVENT_REQUEST_GENERIKS)
			{
			}
			RequestGeneriks::RequestGeneriks( const  network::buffer::BasicBuffer& _copy ) :
				Event::EventRequestGeneriks(),
				network::buffer::BasicBuffer(_copy),
				network::packet::BasicPacket((int)Event::EVENT_REQUEST_GENERIKS)
			{
			}

			RequestGeneriks::RequestGeneriks( const RequestGeneriks& _copy ) :
				Event::EventRequestGeneriks(_copy),
				network::buffer::BasicBuffer(_copy),
				network::packet::BasicPacket(_copy)
			{
			}

			RequestGeneriks::RequestGeneriks(boost::shared_ptr< std::vector< unsigned char > > _receive_buffer) :
				Event::EventRequestGeneriks(),
				network::buffer::BasicBuffer(_receive_buffer),
				network::packet::BasicPacket(getId())
			{
			}

			void RequestGeneriks::handle( network::session_ptr _session,  network::buffer::BasicBuffer& _packet)
			{
				RequestGeneriks packet(_packet);
				_session->on_packet( packet );
			}

		} //	namespace packet
	} //	//	namespace network
